export type ListType = {
  id: number
  name: string
}
export type ActionType =
  | { type: 'channel/saveChannelList'; payload: ListType[] }
  | { type: 'channel/saveAllChannelList'; payload: ListType[] }

const initState = {
  list: [] as ListType[], //用户的频道列表
  allList: [] as ListType[], //所有的频道列表
}

export default function ChannelReducer(state = initState, action: ActionType) {
  switch (action.type) {
    case 'channel/saveChannelList':
      return { ...state, list: action.payload }
    case 'channel/saveAllChannelList':
      return { ...state, allList: action.payload }
    default:
      return state
  }
}
